<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'adddis.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<style type="text/css">
		#contrainer{
			width: 500px;
			height: 600px;
			margin: 0 auto;
		}
		.red{
			color: #F00;
		}
		.greed{
			color: #0F0;
		}
	</style>
	<link rel="stylesheet" type="text/css" href="date/jquery.datetimepicker.css"/>
	<script src="date/jquery.js"></script>
	<script src="date/jquery.datetimepicker.js"></script>
	<script type="text/javascript">
	function checkpm1(){
		var reg = /^\d{1,}$/;
		var pm1 = $("#pm1").val();
		var pm2 = $("#pm2").val();
		if(reg.test(pm1)){
			$("#pm1e").html("正确");
			$("#pm1e").removeClass("red");
			$("#pm1e").addClass("greed");
			return true;
		}else{
			$("#pm1e").html("必须是数字");
			$("#pm1e").removeClass("greed");
			$("#pm1e").addClass("red");
			return false;
		}
	}
	function checkpm2(){
		var reg = /^\d{1,}$/;
		var pm2 = $("#pm2").val();
		if(reg.test(pm2)){
			$("#pm2e").html("正确");
			$("#pm2e").removeClass("red");
			$("#pm2e").addClass("greed");
			return true;
		}else{
			$("#pm2e").html("必须是数字");
			$("#pm2e").removeClass("greed");
			$("#pm2e").addClass("red");
			return false;
		}
	}
	function checkday(){
		var day = $("#day").val();
		if(day.length==0){
			$("#daye").html("必须填写");
			$("#daye").removeClass("greed");
			$("#daye").addClass("red");
			return false;
		}else{
			$("#daye").html("正确");
			$("#daye").removeClass("red");
			$("#daye").addClass("greed");
			return true;
		}
	}
	function checksta(){
		var sta = $("#sta").val();
		if(sta.length==0){
			alert(sta);
			$("#stae").html("必须填写");
			$("#stae").removeClass("greed");
			$("#stae").addClass("red");
			return false;
		}else{
			$("#stae").html("正确");
			$("#stae").removeClass("red");
			$("#stae").addClass("greed");
			return true;
		}
	}
	$(function(){
		$("#day").datetimepicker();
		$("#day").click(function(){
			datepicker:true;
			timepicker:true;
		});
		
		
		$("#pm1").blur(checkpm1);
		$("#pm2").blur(checkpm2);
		$("#day").blur(checkday);
		$("#sta").blur(checksta);
		$("#form1").submit(function(){
			var flag = true;
			if(checkpm1() == false) flag = false;
			if(checkpm2() == false) flag = false;
			if(checkday() == false) flag = false;
			if(checksta() == false) flag = false;
			return flag;
		});
	})
	</script>
  </head>
  
  <body>
  <div id="contrainer">
  <form id="form1" action="aqi/aqiAction!addAqi" method="post">
	  <table>
	  	<tr>
	  		<td>
	  			<h1>新增空气质量</h1>
	  		</td>
	  	</tr>
	    	<tr>
	    		<td>
	    			地区:
	    		</td>
	    		<td>
	    			<select name="aqi.dis.id">
	    				<s:iterator value="list">
	    					<option value="<s:property value="id"/>"><s:property value="name"/></option>
	    				</s:iterator>
	    			</select>
	    		</td>
	    	</tr>
	    	<tr>
	    		<td>
	    			检测日期:
	    		</td>
	    		<td>
	    			<input id="day" type="text" name="time" /><span id="daye"></span>
	    		</td>
	    	</tr>
	    	<tr>
	    		<td>
	    			PM10值:
	    		</td>
	    		<td>
	    			<input id="pm1" type="text" name="aqi.pm10" /><span id="pm1e"></span>
	    		</td>
	    	</tr>
	    	<tr>
	    		<td>
	    			PM2.5值:
	    		</td>
	    		<td>
	    			<input id="pm2" type="text" name="aqi.pm2p5" /><span id="pm2e"></span>
	    		</td>
	    	</tr>
	    	<tr>
	    		<td>
	    			检测站:
	    		</td>
	    		<td>
	    			<input id="sta" type="text" name="aqi.monitoring_station" /><span id="stae"></span>
	    		</td>
	    	</tr>
	    	<tr>
	    		<td>
	    			<input type="submit" value="提交" />
	    		</td>
	    		<td>
	    			<input type="button" value="返回" onclick="javascript:location.href='aqi/aqiAction!show?page.nowpage=${page.nowpage}&type=${type}'" />
	    		</td>
	    	</tr>
	  </table>
	  </form>
  </div>
  </body>
  <s:debug></s:debug>
</html>
